package com.lin.maker.command;

import com.lin.maker.model.MainTemplate;
import lombok.Data;
import picocli.CommandLine;

import java.util.concurrent.Callable;

@CommandLine.Command(name = "testArgGroup", description = "测试参数组",mixinStandardHelpOptions = true)
public class TestArgGroupCommand implements Callable {
    /**
     * 是否循环
     */
    @CommandLine.Option(names = {"-l", "--loop"}, description = "是否循环",interactive = true, arity = "0..1",echo = true)
    private boolean loop;

    @CommandLine.Option(names = {"-need","needGit"},description = "是否需要git",interactive = true,arity = "0..1",echo = true)
    private boolean needGit;

    @CommandLine.ArgGroup(exclusive = false, heading = "核心模板%n")
    MainTemplate mainTemplate;

    @Override
    public Object call() throws Exception {
        System.out.println(needGit);
        System.out.println(loop);
        System.out.println(mainTemplate);
        return null;
    }

    @Data
    static class MainTemplate{
        /**
         * 作者名称
         */
        @CommandLine.Option(names = {"-mainTemplate.a", "--mainTemplate.author"}, description = "作者",interactive = true, arity = "0..1",echo = true)
        private String author = "lin";

        /**
         * 结果输出
         */
        @CommandLine.Option(names = {"-mainTemplate.o", "--mainTemplate.output"}, description = "输出",interactive = true, arity = "0..1",echo = true)
        private String output = "sum = ";
    }

    public static void main(String[] args) {
        CommandLine commandLine = new CommandLine(TestArgGroupCommand.class);
//        commandLine.execute("-l", "-mainTemplate.a", "--mainTemplate.output");
        commandLine.execute("--help");
        commandLine.execute(args);
    }
}
